package date;

import java.time.LocalDate;

/**
 * @author lyy
 * @date 2021/12/20
 */
public class LocalDateTest {
    public static void main(String[] args) {
        LocalDate now = LocalDate.now();
        System.out.println("当前日期：" + now.getYear());
        System.out.println("当前月：" + now.getMonth());
        System.out.println("当前月（数字）：" + now.getMonthValue());
        System.out.println("几号：" + now.getDayOfMonth());
        System.out.println("周几：" + now.getDayOfWeek());
        LocalDate plusYears = now.plusYears(1);
        System.out.println("加一年后：" + plusYears.getYear());
        boolean before = now.isBefore(plusYears);
        System.out.println("当前日期是否在加一年后的日期之前：" + before);
        // 当前日期是否大于另一个日期，-1小于 0等于 1大于
        System.out.println(now.compareTo(plusYears));
        boolean equal = now.isEqual(LocalDate.now());
        System.out.println("两个日期是否相等：" + equal);
    }
}
